package com.shumei.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.shumei.dao.mapper.EmploymentMapper;
import com.shumei.dao.pojo.Application;
import com.shumei.dao.pojo.Employment;
import com.shumei.service.EmploymentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class EmploymentServiceImpl implements EmploymentService {
    @Autowired
    EmploymentMapper employmentMapper;
    @Override
    public List<Employment> selectEmployment() {
        List<Employment> employments=employmentMapper.selectList(null);

        return employments;
    }

    @Override
    public void insertEmployment(Employment employment) {
        int i = employmentMapper.insert(employment);
        if (i > 0) {
            System.out.println("录用表插入成功");

        } else {
            System.out.println("录用表插入失败");

        }
    }

    @Override
    public void updateEmployment(Employment employment) {
        QueryWrapper<Employment> wrapper=new QueryWrapper<Employment>();
        wrapper.eq("id",employment.getId());

        if (employmentMapper.update(employment,wrapper)>0){
            System.out.println("修改成功");
        }
        else {
            System.out.println("修改失败");
        }
    }
    @Override
    public void deleteEmployment(int id){
        int i=employmentMapper.deleteById(id);
        if (i>0) {
            System.out.println("删除成功");
        }else{
            System.out.println("删除失败");
        }
    }
}
